// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   QSAdminServerConfig.java

package org.quickserver.util.xmlreader;

import org.quickserver.net.qsadmin.QSAdminServer;

// Referenced classes of package org.quickserver.util.xmlreader:
//            BasicServerConfig, ServerMode, ObjectPoolConfig, AccessConstraintConfig, 
//            ServerHooks, Secure, AdvancedSettings

public class QSAdminServerConfig extends BasicServerConfig
{

    public QSAdminServerConfig()
    {
        commandShellEnabled = "false";
        commandShellPromptName = "QSAdmin";
        setName((new StringBuilder("QSAdminServer v ")).append(QSAdminServer.getVersion()).toString());
        setPort(9877);
        setBindAddr("127.0.0.1");
        setClientCommandHandler("org.quickserver.net.qsadmin.CommandHandler");
        setClientEventHandler("org.quickserver.net.qsadmin.CommandHandler");
        setClientAuthenticationHandler("org.quickserver.net.qsadmin.Authenticator");
        setClientData("org.quickserver.net.qsadmin.Data");
        setMaxConnection(1L);
        getServerMode().setBlocking(true);
    }

    public void setCommandPlugin(String plugin)
    {
        if(plugin != null && !plugin.equals(""))
            commandPlugin = plugin;
    }

    public String getCommandPlugin()
    {
        return commandPlugin;
    }

    public void setCommandShellEnable(String enable)
    {
        if(enable != null && !enable.equals(""))
            commandShellEnabled = enable;
    }

    public String getCommandShellEnable()
    {
        return commandShellEnabled;
    }

    public void setCommandShellPromptName(String commandShellPromptName)
    {
        if(commandShellPromptName != null && !commandShellPromptName.equals(""))
            this.commandShellPromptName = commandShellPromptName;
    }

    public String getCommandShellPromptName()
    {
        return commandShellPromptName;
    }

    public String toXML(String pad)
    {
        if(pad == null)
            pad = "";
        StringBuilder sb = new StringBuilder();
        sb.append((new StringBuilder(String.valueOf(pad))).append("<qsadmin-server>\n").toString());
        if(getName() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<name>").append(getName()).append("</name>\n").toString());
        if(getServerBanner() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<server-banner>").append(getServerBanner()).append("</server-banner>\n").toString());
        sb.append((new StringBuilder(String.valueOf(pad))).append("\t<port>").append(getPort()).append("</port>\n").toString());
        sb.append((new StringBuilder(String.valueOf(pad))).append("\t<bind-address>").append(getBindAddr()).append("</bind-address>\n").toString());
        sb.append(getServerMode().toXML((new StringBuilder(String.valueOf(pad))).append("\t").toString()));
        if(getClientEventHandler() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<client-event-handler>").append(getClientEventHandler()).append("</client-event-handler>\n").toString());
        if(getClientCommandHandler() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<client-command-handler>").append(getClientCommandHandler()).append("</client-command-handler>\n").toString());
        if(getClientObjectHandler() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<client-object-handler>").append(getClientObjectHandler()).append("</client-object-handler>\n").toString());
        if(getClientBinaryHandler() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<client-binary-handler>").append(getClientBinaryHandler()).append("</client-binary-handler>\n").toString());
        if(getClientWriteHandler() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<client-write-handler>").append(getClientWriteHandler()).append("</client-write-handler>\n").toString());
        if(getClientAuthenticationHandler() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<client-authentication-handler>").append(getClientAuthenticationHandler()).append("</client-authentication-handler>\n").toString());
        else
        if(getAuthenticator() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<authenticator>").append(getAuthenticator()).append("</authenticator>\n").toString());
        if(getClientData() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<client-data>").append(getClientData()).append("</client-data>\n").toString());
        if(getClientExtendedEventHandler() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<client-extended-event-handler>").append(getClientExtendedEventHandler()).append("</client-extended-event-handler>\n").toString());
        sb.append((new StringBuilder(String.valueOf(pad))).append("\t<timeout>").append(getTimeout()).append("</timeout>\n").toString());
        if(getTimeoutMsg() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<timeout-msg>").append(getTimeoutMsg()).append("</timeout-msg>\n").toString());
        sb.append((new StringBuilder(String.valueOf(pad))).append("\t<max-auth-try>").append(getMaxAuthTry()).append("</max-auth-try>\n").toString());
        if(getMaxAuthTryMsg() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<max-auth-try-msg>").append(getMaxAuthTryMsg()).append("</max-auth-try-msg>\n").toString());
        sb.append((new StringBuilder(String.valueOf(pad))).append("\t<max-connection>").append(getMaxConnection()).append("</max-connection>\n").toString());
        if(getMaxConnectionMsg() != null)
            sb.append((new StringBuilder(String.valueOf(pad))).append("\t<max-connection-msg>").append(getMaxConnectionMsg()).append("</max-connection-msg>\n").toString());
        sb.append(getObjectPoolConfig().toXML((new StringBuilder(String.valueOf(pad))).append("\t").toString()));
        sb.append(pad).append("\t<communication-logging>\n");
        sb.append(pad).append("\t\t<enable>").append(getCommunicationLogging()).append("</enable>\n");
        sb.append(pad).append("\t</communication-logging>\n");
        if(getCommandPlugin() != null)
            sb.append(pad).append("\t<command-plugin>").append(getCommandPlugin()).append("</command-plugin>\n");
        sb.append(pad).append("\t<command-shell>\n");
        sb.append(pad).append("\t\t<enable>").append(getCommandShellEnable()).append("</enable>\n");
        sb.append(pad).append("\t\t<prompt-name>").append(getCommandShellPromptName()).append("</prompt-name>\n");
        sb.append((new StringBuilder(String.valueOf(pad))).append("\t</command-shell>\n").toString());
        if(getAccessConstraintConfig() != null)
            sb.append(getAccessConstraintConfig().toXML((new StringBuilder(String.valueOf(pad))).append("\t").toString()));
        if(getServerHooks() != null)
            sb.append(getServerHooks().toXML((new StringBuilder(String.valueOf(pad))).append("\t").toString()));
        sb.append(getSecure().toXML((new StringBuilder(String.valueOf(pad))).append("\t").toString()));
        sb.append(getAdvancedSettings().toXML((new StringBuilder(String.valueOf(pad))).append("\t").toString()));
        sb.append(pad).append("</qsadmin-server>\n");
        return sb.toString();
    }

    public String toString()
    {
        return toXML(null);
    }

    private String commandPlugin;
    private String commandShellEnabled;
    private String commandShellPromptName;
}
